package com.molyfun.parents.activity.record.itemview;

import android.content.Context;

import com.molyfun.parents.rest.bean.RecordResponse;

/**
 * Created by william(liuchao.hit@gmail.com).
 * Date:11/3/16.
 */
public class RecordViewFactory {

    //1:图片 2:视频 3:音频 4:文字

    public static interface RecordType {
        public static int RecordTypeText = 4;
        public static int RecordTypeVoice = 3;
        public static int RecordTypeImage = 1;
        public static int RecordTypeVideo = 2;
        public static int RecordTypeFile = 5;
    }

    public static BaseRecordView getView(Context context, RecordResponse.RecordBean recordBean) {
        switch (recordBean.getType()) {

            case RecordType.RecordTypeText:
                RecordTextView recordTextView = new RecordTextView(context);
                recordTextView.initData(recordBean);
//                return RecordTextView(recordBean);
                return recordTextView;

            case RecordType.RecordTypeVoice:
                RecordVoiceView recordVoiceView = new RecordVoiceView(context);
                recordVoiceView.initData(recordBean);
//                return RecordTextView(recordBean);
                return recordVoiceView;

            case RecordType.RecordTypeImage:
                if (recordBean instanceof RecordResponse.PlaceHolderRecordBean) {
                    //占位view
                    RecordPlaceholderImageView recordImageView = new RecordPlaceholderImageView(context);
                    recordImageView.initData((RecordResponse.PlaceHolderRecordBean) recordBean);
//                return RecordTextView(recordBean);
                    return recordImageView;
                } else {
                    RecordImageView recordImageView = new RecordImageView(context);
                    recordImageView.initData(recordBean);
//                return RecordTextView(recordBean);
                    return recordImageView;
                }
            case RecordType.RecordTypeFile:
                RecordFileView recordFileView = new RecordFileView(context);
                recordFileView.initData(recordBean);
                return recordFileView;
            case RecordType.RecordTypeVideo:
            default:
                if (recordBean instanceof RecordResponse.PlaceHolderRecordBean) {
                    //占位view
                    RecordPlaceholderVideoView recordVideoView = new RecordPlaceholderVideoView(context);
                    recordVideoView.initData((RecordResponse.PlaceHolderRecordBean) recordBean);
                    return recordVideoView;
                } else {
                    RecordVideoView recordVideoView = new RecordVideoView(context);
                    recordVideoView.initData(recordBean);
                    return recordVideoView;
                }


        }
    }

}
